﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Laboratory.Projects.Dto;
using Abp.Domain.Repositories;
using Laboratory.Entities;
using Abp.UI;
using Laboratory.IRepositories;
using AutoMapper;

namespace Laboratory.Projects
{
    public class ProjectService : LaboratoryAppServiceBase, IProjectService
    {
        private readonly IProjectRepository _projectRepository;
        public ProjectService(IProjectRepository cityRepository)
        {
            _projectRepository = cityRepository;
        }
        //public GetCitiesOutput GetCities(GetCityInput input)
        //{
        //    //根据不同条件进行查询不同的结果

        //    //Mapper.CreateMap<Cities, CityOutput>();
        //    //根据城市名称查询城市数据
        //    if (!string.IsNullOrEmpty(input.Name))
        //    {
        //        var cityEntity = _cityRepository.GetAllList(c => c.Name == input.Name).FirstOrDefault();
        //        return new GetCitiesOutput() { CityDto = Mapper.Map<CityDto>(cityEntity) };
        //    }
        //    //根据省份编码查询城市数据
        //    if (!string.IsNullOrEmpty(input.ProvinceCode))
        //    {
        //        var cityEntityList = _cityRepository.GetAllList(c => c.ProvinceCode == input.ProvinceCode);
        //        return new GetCitiesOutput() { CityDtoList = Mapper.Map<List<CityDto>>(cityEntityList) };
        //    }

        //    return null;
        //}

    
   
        public void CreateCity(CreateProjectInput input)
        {
            Project city = _projectRepository.FirstOrDefault(c => c.Name == input.Name);
            if (city != null)
            {
                throw new UserFriendlyException("该城市数据已经存在！");
            }

            city = new Project(input.Name,1) ;


            _projectRepository.Insert(city);
        }

        public List<ProjectDto> GetCities()
        {
            var People = Mapper.Map<List<ProjectDto>>(new List<Project>());


            throw new NotImplementedException();
        }
    }
}
